package com.atguigu.mapreduce01;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import org.apache.hadoop.io.NullWritable;

import java.io.IOException;
import java.util.List;

/**
 * 从hbase中读取数据
 *
 * @author lvbingbing
 * @date 2020-07-26 15:03
 */
public class ReadFruitMapper extends TableMapper<NullWritable, Put> {
    @Override
    protected void map(ImmutableBytesWritable key, Result result, Context context) throws IOException, InterruptedException {

        Put put = new Put(key.get());

        List<Cell> cells = result.listCells();

        for (Cell cell : cells) {
            put.add(cell);
        }

        context.write(NullWritable.get(), put);
    }
}
